home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / win_make.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-25  |  4.2 KB  |  141 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: win_make.c,v 1.3 89/09/25 08:57:03 sau Exp $
  9.     $Source: /m1/mgr.new/src/RCS/win_make.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /m1/mgr.new/src/RCS/win_make.c,v $$Revision: 1.3 $";
  12.  
  13. /* make an alternate window */
  14.  
  15. #include "bitmap.h"
  16. #include "font.h"
  17. #include "defs.h"
  18. #include "window.h"
  19. #include "event.h"
  20. #include <stdio.h>
  21.  
  22. /* manipulte an alternate (client) window - called by put_window() */
  23.  
  24. int
  25. win_make(win,indx)
  26. WINDOW *win;            /* window issuing make-call */
  27. int indx;            /* current index into char string (yuk!) */
  28.    {
  29.    register int *p = W(esc);    /* array of ESC digits */
  30.    int buff[10];
  31.    WINDOW *win2=win, *insert_win();
  32.  
  33.    switch (W(esc_cnt)) {
  34.       case 1:            /*  destroy the window */
  35. #ifdef DEBUG
  36.          dprintf(N)(stderr,"%s: destroying %d\n",W(tty),p[0]);
  37. #endif
  38.          if (p[0]<=0 || W(main)->alt == (WINDOW *) 0) {
  39.             break;
  40.             }
  41.          for (win = W(main)->alt;win!=(WINDOW *) 0; win=W(alt))  {
  42.             if (W(num)==p[0])
  43.                break;
  44.             }
  45.          if (win != (WINDOW *) 0) 
  46.             W(flags) |= W_DIED;
  47.          break;
  48.  
  49.       case 0:        /* goto a new window */
  50.          if (W(num)==p[0] || W(main)->alt == (WINDOW *) 0) {
  51.             break;
  52.             }
  53.          for (win = W(main);win!=(WINDOW *) 0; win=W(alt))  {
  54.             if (W(num)==p[0])
  55.                break;
  56.             }
  57.  
  58.          /* move contents of shell buffer to new window */
  59.  
  60.          if (win != (WINDOW *) 0) {
  61.             W(from_fd) = W(to_fd);
  62.             win2->from_fd = 0;
  63.             W(max) = win2->max - win2->current - indx - 1;
  64.             bcopy(win2->buff + win2->current + indx + 1,W(buff),W(max));
  65.             W(current) = 0;
  66. #ifdef DEBUG
  67.             dprintf(N)(stderr,"%s: xfer %d\r\n",W(tty),W(max));
  68. #endif
  69.             }
  70.          break;
  71.  
  72.       case 3:        /* make a new window */
  73.          p[4] = -1;
  74.          /* no break */
  75.       case 4:        /* new window + specify window number */
  76. #ifdef DEBUG
  77.          dprintf(N)(stderr,"%s: making alternate window\n",W(tty));
  78. #endif
  79.          if (check_window(p[0],p[1],p[2],p[3],-1) == 0) {
  80.                 if (ACTIVE(flags)&W_DUPKEY)
  81.                     sprintf(buff,"%c \n",ACTIVE(dup));
  82.                 else
  83.                     sprintf(buff,"\n");
  84.                 write(ACTIVE(to_fd),buff,strlen(buff));
  85.             break;
  86.             }
  87.  
  88.          if (win!=active)
  89.             cursor_off();
  90.          ACTIVE_OFF();
  91.          if ((active = insert_win((WINDOW *) 0)) == (WINDOW *) 0 ||
  92.                      !setup_window(active,font,p[0],p[1],p[2],p[3])) {
  93.             fprintf(stderr,"Out of memory for window creation -- bye!\n");
  94.             quit();
  95.             }
  96.  
  97.          /* next_window++;  (this needs more thought) */
  98.  
  99.          /* make the window */
  100.  
  101.          set_covered(active);
  102.          border(active,BLK_BDR,WH_BDR);
  103.          CLEAR(ACTIVE(window),BIT_CLR);
  104.          ACTIVE_ON();
  105.          cursor_on();
  106.  
  107. #ifdef DEBUG
  108.          dprintf(N)(stderr,"%s: window created\n",W(tty));
  109. #endif
  110.          /* fix pointer chain */
  111.  
  112.          ACTIVE(to_fd) =  W(to_fd);
  113.          ACTIVE(main) = W(main);
  114.          ACTIVE(pid) =  W(pid);
  115.          ACTIVE(setid) =  W(setid);
  116.          strcpy(ACTIVE(tty),ACTIVE(main)->tty);
  117.          ACTIVE(from_fd) = 0;
  118.          ACTIVE(alt) =  W(main)->alt;
  119.          ACTIVE(main)->alt = active;
  120.             if (p[4] > 0)
  121.             ACTIVE(num) = p[4];
  122.          else if (ACTIVE(alt))
  123.             ACTIVE(num) = ACTIVE(alt)->num + 1;
  124.          else
  125.             ACTIVE(num) = 1;
  126.          
  127. #ifdef DEBUG
  128.          dprintf(N)(stderr,"%s: created num %d\r\n",ACTIVE(tty),ACTIVE(num));
  129. #endif
  130.          if (W(flags)&W_DUPKEY)
  131.             sprintf(buff,"%c %d\n",W(dup),ACTIVE(num));
  132.          else
  133.             sprintf(buff,"%d\n",ACTIVE(num));
  134.          write(ACTIVE(to_fd),buff,strlen(buff));
  135.          clip_bad(active);    /* invalidate clip lists */
  136.          break;
  137.       case 5:        /* nothing */
  138.          break;
  139.      }
  140.    }
  141.